<html>
<head>
    <title>修改收费项目--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<body>
<form action="charge.html" id="myForm" method="post" class="definewidth m20">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">编号</td>
            <td>
                <span id="id1"></span>
                <input type="hidden" id="id" name="id">
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">收费项目名称</td>
            <td><input type="text" id="chargeName" name="chargeName" /></td>
        </tr>

        <tr>
            <td width="10%" class="tableleft">收费金额</td>
            <td><input type="text" id="chargeMoney" name="chargeMoney" /></td>
        </tr>
        <tr>
            <td colspan="2">
                <center>
                    <button type="button" class="btn btn-primary" onclick="update()">保存</button> &nbsp;&nbsp;
                    <button type="button" class="btn btn-success" onclick="black()">返回列表</button>
                </center>
            </td>
        </tr>
    </table>
</form>
    <script type="text/javascript">
        function black(){
            window.location.href="charge.html";
        }

        //获取url
        (function($){
            $.getUrlParam
                = function(name)
            {
                var reg
                    = new RegExp("(^|&)"+
                    name +"=([^&]*)(&|$)");
                var r
                    = window.location.search.substr(1).match(reg);
                if (r!=null) return unescape(r[2]); return null;
            }
        })(jQuery);
        var id = $.getUrlParam('id');

        //显示
        function show() {
            $("#id1").html(id);
            $.ajax({
                url:"/charge/getChargeById?id="+id,
                type:"GET",
                success:function(charge){
                    $("#id").val(charge.id);
                    $("#chargeName").val(charge.chargeName);
                    $("#chargeMoney").val(charge.chargeMoney);
                }
            })
        }
        show();

        function update() {
            $.ajax({
                url:"/charge/updateCharge",
                type:"POST",
                data:$("#myForm").serialize(),
                dataType:"json",
                success:function(ov){
                    alert(ov.msg);
                    if(ov.code==200){
                        black();
                    }
                }
            })
        }
        
    </script>
</body>
</html>
<script>

</script>